package com.iqi.onigao.http;

import java.util.HashMap;
import java.util.Map;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONUtil;

public class ReqData {
	private String sign;
	private long time;
	private Map<String, Object> data;
	private Map<String, Object> common;

	public static ReqData builder() {
		ReqData reqData = new ReqData();
		reqData.time = System.currentTimeMillis();
		reqData.data = new HashMap<>();
		
		reqData.common = new HashMap<>();
		reqData.common.put("channelNo", "-1");
		reqData.common.put("mtype", "3333333");
		reqData.common.put("system", "windows");
		reqData.common.put("systype", "555555");
		reqData.common.put("nettype", "6666666");
		reqData.common.put("mac", "xxxxxxxxxx");
		reqData.common.put("idfa", "7777777");
		reqData.common.put("packageName", "888888888");
		reqData.common.put("version", "1.0.0");
		
		return reqData;
	}
	
	public String build() {
		this.sign = SecureUtil.md5((System.currentTimeMillis() / 53) + JSONUtil.toJsonStr(data) + "sgsginqq");
		return JSONUtil.toJsonStr(this);
	}
	
	public String getSign() {
		return sign;
	}

	public void setSign(String sign) {
		this.sign = sign;
	}

	public long getTime() {
		return time;
	}

	public void setTime(long time) {
		this.time = time;
	}

	public Map<String, Object> getData() {
		return data;
	}

	public void setData(Map<String, Object> data) {
		this.data = data;
	}

	public Map<String, Object> getCommon() {
		return common;
	}

	public void setCommon(Map<String, Object> common) {
		this.common = common;
	}
	
	public ReqData put(String key, Object value) {
		this.data.put(key, value);
		return this;
	}
}
